// ObjectInteractionsPlugin.cpp : Defines the entry point for the application.
//
#include "Dice.h"
#include "stdafx.h"
#include "ObjectInteractionsPlugin.h"
#include "..\Shared\ObjectManager.h"

__declspec(dllexport) IPlugin* __stdcall CreateInstance()
{
	return (IPlugin*)new ObjectInteractionsPlugin();
}

__declspec(dllexport) int __stdcall GetInterfaceVersion(void)
{
	return PluginInterfaceVersion;
}

ObjectInteractionsPlugin::ObjectInteractionsPlugin()
{
	srand((unsigned)time(0));
	m_ModuleInfo.pluginName = "ObjectInteractionsPlugin";
	m_ModuleInfo.author = "Mike Pierce";
	m_ModuleInfo.version = 0x00000001; // 0xMMmmaabb   MM = Major mm = Minor aa = Macro bb = Build
	m_ModuleInfo.numOfCommands = 7;// do this first*
	m_ModuleInfo.commands[0] = "Attack";
	m_ModuleInfo.commands[1] = "Pickup";
	m_ModuleInfo.commands[2] = "Drop";
	m_ModuleInfo.commands[3] = "Use";
	m_ModuleInfo.commands[4] = "Invoke";
	m_ModuleInfo.commands[5] = "Break";
	m_ModuleInfo.commands[6] = "Equip";
}

bool __stdcall ObjectInteractionsPlugin::HandleCommand(Command &NewCommand)
{
	bool Found = false;
	for(int i = 0; i < m_ModuleInfo.numOfCommands; i++)
	{
		if(m_ModuleInfo.commands[i] == NewCommand.name)
		{
			Found = true;
			break;
		}
	}
	if(!Found)
		return false;

	/*
	Command Name: Attack
	Indexing Mode: String & Parent
	Parameter 0: Attacker
	Parameter 1: Defender 
	*/
	if(NewCommand.name == "Attack")
	{
		//1. Check for correct parameters (2)
		if(NewCommand.Arguments.Size() == 2)
		{
			//check that first parameter is a string
			if(NewCommand.Arguments[0].GetType() != AT_STRING)
			{
				NewCommand.Returns.Add(Value("Error","Item needs string index"));
				return true;
			}
			//check that second parameter is a string
			if(NewCommand.Arguments[1].GetType() != AT_STRING)
			{
				NewCommand.Returns.Add(Value("Error","Item needs string index"));
				return true;
			}


			//check first and second parameters for error
			if((*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("Name") == "Error")
				return true;
			if((*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("Name") == "Error")
				return true;


			//get defendenders AC, baseAttack, strengthModifier
			int AC = (*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("AC").ToInt();
			int baseAttack = (*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("BaseAtkBonus").ToInt();
			int StrModifier = (*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("StrModifier").ToInt();

			Object &Actor = (*m_Objects)[NewCommand.Arguments[0]];
			Object &Equipped = Actor["Equipped"];
				

			//2. Attack roll, if d20 Critical Hit, if d1 its a miss
			Dice dice = Dice();
			int attackRoll = dice.RollD20();

			//find the object in the characters LHand and RHand, do an attack based off of the dice stored in that object

			int itemIndex = Equipped.GetBaseAttribute("RHand").ToInt();
			int DiceValue = (*m_Objects)[itemIndex].GetBaseAttribute("DiceValue").ToInt();
			int NumberOfDice = (*m_Objects)[itemIndex].GetBaseAttribute("NumberOfDice").ToInt();	
			int damage = 0;
			//get weapon from right hand, get attributes and calculate attack
			if(itemIndex == -1)
			{
				DiceValue = 3;
				NumberOfDice = 1;
			}

			

			//--------------------------------------------------------------------------

			if(attackRoll == 20 && 20 + baseAttack + StrModifier >= AC)
			{
				//score a critical hit
				//calculate damage based off of weapon roll, pass to function that does weapons (use multiplier)
				//calculate damage - Melee =  Str modifier + enhancement bonus

				//-------------------------------------------------------------------------------
				if(NumberOfDice == 1)
				{
					if(DiceValue == 2)
					{
						damage = (dice.RollD2() * 2) + StrModifier;
					}
					else if(DiceValue == 3)
					{
						damage = (dice.RollD3() * 2) + StrModifier;
					}
					else if(DiceValue == 4)
					{
						damage = (dice.RollD4() * 2) + StrModifier;
					}
					else if(DiceValue == 6)
					{
						damage = (dice.RollD6() * 2) + StrModifier;
					}
					else if(DiceValue == 8)
					{
						damage = (dice.RollD8() * 2) + StrModifier;
					}
					else if(DiceValue == 10)
					{
						damage = (dice.RollD10() * 2) + StrModifier;
					}
					else if(DiceValue == 12)
					{
						damage = (dice.RollD12() * 2) + StrModifier;
					}
					else if(DiceValue == 20)
					{
						damage = (dice.RollD20() * 2) + StrModifier;
					}
					m_Objects->GetBaseAttributeFromObject(NewCommand.Arguments[1],"CureHP") -= damage;
					return true;
				}

				else if(NumberOfDice == 2)
				{
					if(DiceValue == 2)
					{	
						int x = dice.RollD2();
						damage = ((x + dice.RollD2()) * 2) + StrModifier;
					}
					else if(DiceValue == 3)
					{
						int x = dice.RollD3();
						damage = ((x + dice.RollD2()) * 3) + StrModifier;
					}
					else if(DiceValue == 4)
					{
						int x = dice.RollD4();
						damage = ((x + dice.RollD2()) * 4) + StrModifier;
					}
					else if(DiceValue == 6)
					{
						int x = dice.RollD6();
						damage = ((x + dice.RollD2()) * 6) + StrModifier;
					}
					else if(DiceValue == 8)
					{
						int x = dice.RollD8();
						damage = ((x + dice.RollD2()) * 8) + StrModifier;
					}
					else if(DiceValue == 10)
					{
						int x = dice.RollD2();
						damage = ((x + dice.RollD10()) * 10) + StrModifier;
					}
					else if(DiceValue == 12)
					{
						int x = dice.RollD2();
						damage = ((x + dice.RollD12()) * 12) + StrModifier;
					}
					else if(DiceValue == 20)
					{
						int x = dice.RollD20();
						damage = ((x + dice.RollD2()) * 20) + StrModifier;
					}
					m_Objects->GetBaseAttributeFromObject(NewCommand.Arguments[1],"CureHP") -= damage;
					return true;
				}
				//damage for attack has been calculated, decrement enemies HP
			}//end of critical hit
			else if(attackRoll == 1)
			{
				return true;
			}
			//regular attack role
			else if(attackRoll + baseAttack + StrModifier >= AC)
			{
			//calculate regular damag,  Melee =  Str modifier + enhancement bonus
				//-------------------------------------------------------------------------------
			if(NumberOfDice == 1)
			{
				if(DiceValue == 2)
				{
					damage = (dice.RollD2()) + StrModifier;
				}
				else if(DiceValue == 3)
				{
					damage = (dice.RollD3()) + StrModifier;
				}
				else if(DiceValue == 4)
				{
					damage = (dice.RollD4()) + StrModifier;
				}
				else if(DiceValue == 6)
				{
					damage = (dice.RollD6()) + StrModifier;
				}
				else if(DiceValue == 8)
				{
					damage = (dice.RollD8()) + StrModifier;
				}
				else if(DiceValue == 10)
				{
					damage = (dice.RollD10()) + StrModifier;
				}
				else if(DiceValue == 12)
				{
					damage = (dice.RollD12()) + StrModifier;
				}
				else if(DiceValue == 20)
				{
					damage = (dice.RollD20()) + StrModifier;
				}
				m_Objects->GetBaseAttributeFromObject(NewCommand.Arguments[1],"CureHP") -= damage;
				return true;
			}

			else if(NumberOfDice == 2)
			{
				if(DiceValue == 2)
				{	
					int x = dice.RollD2();
					damage = ((x + dice.RollD2())) + StrModifier;
				}
				else if(DiceValue == 3)
				{
					int x = dice.RollD3();
					damage = ((x + dice.RollD3())) + StrModifier;
				}
				else if(DiceValue == 4)
				{
					int x = dice.RollD4();
					damage = ((x + dice.RollD4())) + StrModifier;
				}
				else if(DiceValue == 6)
				{
					int x = dice.RollD6();
					damage = ((x + dice.RollD6())) + StrModifier;
				}
				else if(DiceValue == 8)
				{
					int x = dice.RollD8();
					damage = ((x + dice.RollD8())) + StrModifier;
				}
				else if(DiceValue == 10)
				{
					int x = dice.RollD2();
					damage = ((x + dice.RollD10())) + StrModifier;
				}
				else if(DiceValue == 12)
				{
					int x = dice.RollD2();
					damage = ((x + dice.RollD12())) + StrModifier;
				}
				else if(DiceValue == 20)
				{
					int x = dice.RollD20();
					damage = ((x + dice.RollD20())) + StrModifier;
				}
				m_Objects->GetBaseAttributeFromObject(NewCommand.Arguments[1],"CureHP") -= damage;
				return true;
			}

		}//end of reg attack roll
		
				/*
				if((*m_Objects)[NewCommand.Arguments[2]].GetBaseAttribute("Name") == "ShortSword")
				{
					int damage = (dice.RollD6() * 2) + StrModifier;
					m_Objects->GetBaseAttributeFromObject(NewCommand.Arguments[1],"CureHP") -= damage;
					*/
	/*				if (m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("CureHP").ToInt() <= 0) //?????
					{
						Command CharacterDeath;
						strcpy_s(CharacterDeath.name, NAMELEN, "CharDeath");
						CharacterDeath.Arguments.Add(NewCommand.Arguments[1]);
					    m_Manager->HandleCommand(CharacterDeath);
					}*/
			/*	return true;
				}
				else if((*m_Objects)[NewCommand.Arguments[2]].GetBaseAttribute("Name") == "Fist")
				{
					int damage = (dice.RollD3() * 2) + StrModifier;
					m_Objects->GetBaseAttributeFromObject(NewCommand.Arguments[1],"CureHP") -= damage;

					/*if (m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("CureHP").ToInt() <= 0) //?????
					{
						Command CharacterDeath;
					 	strcpy_s(CharacterDeath.name, NAMELEN, "CharDeath");
						CharacterDeath.Arguments.Add(NewCommand.Arguments[1]);
					    m_Manager->HandleCommand(CharacterDeath);
					}*/
		/*			return true;
				}
			}
			//a 1 always results in a miss
			else if(attackRoll == 1)
			{
				return true;
			}
		//Regular attack
		else if(attackRoll + baseAttack + StrModifier >= AC)
		{
			//calculate damage based off of weapon (roll dice)
			//calculate damage - Melee =  Str modifier + enhancement bonus
			//Modify HP
			if((*m_Objects)[NewCommand.Arguments[2]].GetBaseAttribute("Name") == "ShortSword")
			{
				int damage = dice.RollD6() + StrModifier;
				m_Objects->GetBaseAttributeFromObject(NewCommand.Arguments[1],"CureHP") -= damage;

			/*	if (m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("CureHP").ToInt() <= 0) //?????
				{
					Command CharacterDeath;
					strcpy_s(CharacterDeath.name, NAMELEN, "CharDeath");
					CharacterDeath.Arguments.Add(NewCommand.Arguments[1]);
				    m_Manager->HandleCommand(CharacterDeath);
				}*/
			//	return true;
		}
		return true;
}//end of Attack

		/*	if((*m_Objects)[NewCommand.Arguments[2]].GetBaseAttribute("Name") == "Fist")
			{
				int damage = dice.RollD3() + StrModifier;
			/*	m_Objects->GetBaseAttributeFromObject(NewCommand.Arguments[1],"CureHP") -= damage;
				if (m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("CureHP").ToInt() <= 0) //?????
				{
					Command CharacterDeath;
					strcpy_s(CharacterDeath.name, NAMELEN, "CharDeath");
					CharacterDeath.Arguments.Add(NewCommand.Arguments[1]);
				    m_Manager->HandleCommand(CharacterDeath);
				}*/
		//		return true;
	//		}
	/*	}
		else  //no hit was made
		{
			return true;
		}
		
	
		//m_Objects->GetBaseAttributeFromObject(NewCommand.Arguments[0],"CureHP") -= 5;
		//Do the command
		//Class.Command();
		//m_Ojects-> same as m_ObjectManager in GameEngine...
		/*
		NewCommand.Returns.Add(Value("Error","Need "));
		Object &Attacker = (*m_Objects)[NewCommand.Arguments["Item"]];
		Object &Item = Attacker[NewCommand.Arguments["Item"]];
		if(Attacker.GetBaseAttribute("Name") == "Error")
			NewCommand.Returns["Error"] += "Player Object ";
		if(m_Objects->GetBaseAttributeFromObject(NewCommand.Arguments[0],"Name") == "Error")
			NewCommand.Returns["Error"] += "Player Object ";
		if(m_Objects->GetBaseAttributeFromObject(NewCommand.Arguments[1],"Name") == "Error")
			NewCommand.Returns["Error"] += "Target Object ";
		if(m_Objects->GetChildFromObject(NewCommand.Arguments[0], NewCommand.Arguments[2]).GetBaseAttribute("Name") == "Error")
			NewCommand.Returns["Error"] += "Item to use Object ";
		Item.GetBaseAttribute("EP") -= 5;
		return true;
		*/
	
	/*
	Command Name: Pickup //if the item is being picked up, easiest to identify by a global number or name
	Parameter 0: Character Object
	Parameter 1: Item
	*/
	if(NewCommand.name == "Pickup")
	{

		
		//1. Check for correct parameters (2)
		if(NewCommand.Arguments.Size() == 2)
		{
			//check that first parameter is a string
			if(NewCommand.Arguments[0].GetType() != AT_STRING)
			{
				NewCommand.Returns.Add(Value("Error","Item needs string index"));
				return true;
			}
			//check that second parameter is a string
			if(NewCommand.Arguments[1].GetType() != AT_STRING)
				return true;
			//check first and second parameters for error
			if((*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("Name") == "Error")
				return true;
			if((*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("Name") == "Error")
				return true;
		    //2. Find item to drop			
			//check for parent of Item Object
			if((*m_Objects)[NewCommand.Arguments[1]].Parent != NULL)// checks the parent of the second index object
			{
				//3. remove item from parent of Item(characters child, 
				m_Objects->RemoveChildFromObject((*m_Objects)[NewCommand.Arguments[1]].Parent->GetBaseAttribute("Name"), NewCommand.Arguments[1]);
				// add object to parent of character (room)
				// store location of object (should be same as characters)

			}
			// make item child of character 
			// first argument refers to the 
			m_Objects->AddChildToObject(NewCommand.Arguments[0], NewCommand.Arguments[1]);
			(*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("X") = (*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("X");
			(*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("Y") = (*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("Y");
		}
	return true;
	}
	/*
		1. Check for correct parameters
		2. Remove Item from Parent Object
		3. Add item to characters items
		4. return success or failure

	}
	/*
	Command Name: Drop //character object will be holding the item (must be removed from character object)
	Parameter 0: Character Object
	Parameter 1: Item
	*/
	if(NewCommand.name == "Drop")
	{
		//1. Check for correct parameters (2)
		if(NewCommand.Arguments.Size() == 2)
		{
			//check that first parameter is a string
			if(NewCommand.Arguments[0].GetType() != AT_STRING)
			{
				NewCommand.Returns.Add(Value("Error","Item needs string index"));
				return true;
			}
			//check that second parameter is a string
			if(NewCommand.Arguments[1].GetType() != AT_STRING)
				return true;
			//check first and second parameters for error
			if((*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("Name") == "Error")
				return true;
			if((*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("Name") == "Error")
				return true;
		    //2. Find item to drop			
			//check for parent of Character Object
			if((*m_Objects)[NewCommand.Arguments[1]].Parent != NULL)// checks the parent of the first index object
			{
				//3. remove item from character(characters child, (this removes reference from parent of 1, object 1)
				m_Objects->RemoveChildFromObject((*m_Objects)[NewCommand.Arguments[1]].Parent->GetBaseAttribute("Name"), NewCommand.Arguments[1]);
				// add object to parent of character (room)
				// store location of object (should be same as characters)

			}
			// Add the object to the parent of character (room)
			// first argument refers to the 
			m_Objects->AddChildToObject((*m_Objects)[NewCommand.Arguments[0]].Parent->GetBaseAttribute("Name"), NewCommand.Arguments[1]);
			(*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("X") = (*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("X").ToInt();
			(*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("Y") = (*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("Y").ToInt();
		}
		return true;
	}

	/*
	Command Name: use
	Parameter 0: Character object
	parameter 1: Item (Each item should have onuse code)
	*/
	if(NewCommand.name == "Use")
	{
		//check for the correct parameters (2)
		if(NewCommand.Arguments.Size() == 2)
		{
			//check first argument is a string
			if(NewCommand.Arguments[0].GetType() != AT_STRING)
			{
				NewCommand.Returns.Add(Value("Error","Arg 0 needs a string index"));
				return true;
			}
			//check that second parameter is a string
			if(NewCommand.Arguments[1].GetType() != AT_STRING)
			{
				NewCommand.Returns.Add(Value("Error","Arg 1 needs a string index"));
				return true;
			}

			//check first and second parameters for error
			if((*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("Name") == "Error")
				return true;
			if((*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("Name") == "Error")
				return true;

			//check for item that is being used
			if((*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("Name") == "SmHealthPotion")
			{
				int healthBonus = (*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("SmHealthPotion").ToInt();
				//error checking for hp??
				m_Objects->GetBaseAttributeFromObject(NewCommand.Arguments[0],"CureHP") += healthBonus;
				return true;
			}
		}//end if size == 2
		//if no matching item was found
		NewCommand.Returns.Add(Value("Error","No matching item was found"));
		return true;
	}
	/*
	Command Name: Invoke // object with an invoke attribute attached to it
	Parameter 0: Character Object
	Parameter 1: Item
	Parameter 2: Invoke Attribute
	*/
	if(NewCommand.name == "Invoke")
	{
		//1. Check for correct parameters (2)
		if(NewCommand.Arguments.Size() == 3)
		{
			//check that first parameter is a string
			if(NewCommand.Arguments[0].GetType() != AT_STRING)
			{
				NewCommand.Returns.Add(Value("Error","Character needs string index"));
				return true;
			}
			//check that second parameter is a string
			if(NewCommand.Arguments[1].GetType() != AT_STRING)
			{
				NewCommand.Returns.Add(Value("Error","Item needs string index"));
				return true;
			}

			if(NewCommand.Arguments[1].GetType() != AT_STRING)
			{
				NewCommand.Returns.Add(Value("Error","Invoke attribute needs string index"));
				return true;
			}

			//check parameters for errors
			if((*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("Name") == "Error")
				return true;
			if((*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("Name") == "Error")
				return true;
			if((*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("Name") == "Error")
				return true;
		}
		return true;
				/*
		1. Check for correct parameteres
		2. Find item to be used
		3. Check for correct invoke attribute
		4. Use invoke attribute to modify item (character)
		5. *If it is for a number of turns, we will need an attribute in character to keep track of length
		6. Return success or failure
		*/

	}//end of invoke

		
	/*
	Command Name: Break
	Parameter 0: Character Object
	Parameter 1: Item to break
	*/
	if(NewCommand.name == "Break")
	{
		//1. Check for correct parameters (2)
		if(NewCommand.Arguments.Size() == 2)
		{
			//check that first parameter is a string
			if(NewCommand.Arguments[0].GetType() != AT_STRING)
			{
				NewCommand.Returns.Add(Value("Error","Character needs string index"));
				return true;
			}
			//check that second parameter is a string
			if(NewCommand.Arguments[1].GetType() != AT_STRING)
			{
				NewCommand.Returns.Add(Value("Error","Item to break needs string index"));
				return true;
			}
			//check first and second parameters for error
			if((*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("Name") == "Error")
				return true;
			if((*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("Name") == "Error")
				return true;

			//get Item to break's AC, character's baseAttack and strengthModifier
			int AC = (*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("AC").ToInt();
			int baseAttack = (*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("BaseAtkBonus").ToInt();
			int StrModifier = (*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("StrModifier").ToInt();

			//2. roll to break item, if attack + bonuses is >= then AC then breaking the object by sudden force is successful
			Dice dice = Dice();
			int attackRoll = dice.RollD20();
			if(attackRoll + baseAttack + StrModifier >= AC)
			{
				//remove item from parent, item will no longer be accessable
				m_Objects->RemoveChildFromObject((*m_Objects)[NewCommand.Arguments[1]].Parent->GetBaseAttribute("Name"), NewCommand.Arguments[1]);
				//if the object has children drop them
				if(m_Objects->GetBaseAttributeFromObject(NewCommand.Arguments[1],"Name") != "Error") // checks that the argument at i is a object in the object manager
				for(int j = 0; j < m_Objects->GetNumberOfChildrenFromObject(NewCommand.Arguments[1]); j++) //loop through all of the children of the object
				{
					// add object to parent of item (room)
					// store location of object (should be same as characters)
					m_Objects->AddChildToObject((*m_Objects)[NewCommand.Arguments[1]].Parent->GetBaseAttribute("Name"), (*m_Objects)[NewCommand.Arguments[1]][j].GetBaseAttribute("Name"));
					(*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("X") = (*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("X").ToInt();
					(*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("Y") = (*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("Y").ToInt();
					// remove item from broken item
					m_Objects->RemoveChildFromObject((*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute(j), NewCommand.Arguments[1]);
									
				}
			
				//m_Objects->AddChildToObject((*m_Objects)[NewCommand.Arguments[1]].Parent->GetBaseAttribute("Name"), NewCommand.Arguments[1]);
			}
			else
			{
				return true;
			}
		}
	return true;
	}
	//Paramater 0: Character Object
	//Parameter 1: Item to equip
	if(NewCommand.name == "Equip")
	{
		//1. Check for correct parameters (2)
		if(NewCommand.Arguments.Size() == 2)
		{
			//check that first parameter is a string
			if(NewCommand.Arguments[0].GetType() != AT_STRING)
			{
				NewCommand.Returns.Add(Value("Error","Character needs string index"));
				return true;
			}
			//check that second parameter is a string
			if(NewCommand.Arguments[1].GetType() != AT_STRING)
			{
				NewCommand.Returns.Add(Value("Error","Item to Equip needs string index"));
				return true;
			}
			//check first and second parameters for error
			if((*m_Objects)[NewCommand.Arguments[0]].GetBaseAttribute("Name") == "Error")
				return true;
			if((*m_Objects)[NewCommand.Arguments[1]].GetBaseAttribute("Name") == "Error")
				return true;
			Object &Actor = (*m_Objects)[NewCommand.Arguments[0]];
			Object &Equipped = Actor["Equipped"];
			Object &Item = (*m_Objects)[NewCommand.Arguments[1]];
			Value &Location = Item.GetBaseAttribute("EquipLocation");
			//need to check where the item can be equipped
			if(Location == "Head")
			{
				//equip item string index in second argument to Characters Head
				Equipped.GetBaseAttribute("Head") = Item.GetIndex();
			}
			else if(Location == "Feet")
			{
				//equip item string index in second argument to Characters Feet
				Equipped.GetBaseAttribute("Feet") = Item.GetIndex();
			}
			else if(Location == "RHand")
			{
				//equip item string index in second argument to Characters RHand
				std::cout << Equipped.GetBaseAttribute("RHand") << std::endl;
				Equipped.GetBaseAttribute("RHand") = Item.GetIndex();
				std::cout << Equipped.GetBaseAttribute("RHand") << std::endl;

			}
			if(Location == "LHand")
			{
				//equip item string index in second argument to Characters LHand
				Equipped.GetBaseAttribute("LHand") = Item.GetIndex();
			}
			if(Location == "Chest")
			{
				//equip item string index in second argument to Characters Chest
				Equipped.GetBaseAttribute("Chest") = Item.GetIndex();
			}
			//need to 
		//Equip item
		}
	}
		return true;
}//end of handler


/* FUNCTIONS FOR ABOVE COMMANDS
int AttackRole()
1. Roll a d20 dice, return result

int AttackBonus(Character*) //this may be better w/out a function
1. check character attributes to find attack bonus


int DefenseBonus(Character*) //this may be better w/out a function
1. use characters attributes plus armor to calculate

int WeaponDamage(weapon)
1. This info should be stored in the weapon itself (maybe better w/out function)

int ModifyHP(character*)

bool DeleteItem(character*, item)

bool AddItem(character*, item)

bool usePotion(character*, item)

*/
